package doyouknow.group.CnAndZhb.service.impl;

import doyouknow.group.CnAndZhb.entity.TblVirtualGateway;
import doyouknow.group.CnAndZhb.dao.master.TblVirtualGatewayDao;
import doyouknow.group.CnAndZhb.service.TblVirtualGatewayService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TblVirtualGateway)表服务实现类
 *
 * @author cn
 * @since 2020-11-03 20:50:41
 */
@Service("tblVirtualGatewayService")
public class TblVirtualGatewayServiceImpl implements TblVirtualGatewayService {
    @Resource
    private TblVirtualGatewayDao tblVirtualGatewayDao;

    /**
     * 通过ID查询单条数据
     *
     * @param gatewayidx 主键
     * @return 实例对象
     */
    @Override
    public TblVirtualGateway queryById(Integer gatewayidx) {
        return this.tblVirtualGatewayDao.queryById(gatewayidx);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<TblVirtualGateway> queryAllByLimit(int offset, int limit) {
        return this.tblVirtualGatewayDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tblVirtualGateway 实例对象
     * @return 实例对象
     */
    @Override
    public TblVirtualGateway insert(TblVirtualGateway tblVirtualGateway) {
        this.tblVirtualGatewayDao.insert(tblVirtualGateway);
        return tblVirtualGateway;
    }

    /**
     * 修改数据
     *
     * @param tblVirtualGateway 实例对象
     * @return 实例对象
     */
    @Override
    public TblVirtualGateway update(TblVirtualGateway tblVirtualGateway) {
        this.tblVirtualGatewayDao.update(tblVirtualGateway);
        return this.queryById(tblVirtualGateway.getGatewayidx());
    }

    /**
     * 通过主键删除数据
     *
     * @param gatewayidx 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer gatewayidx) {
        return this.tblVirtualGatewayDao.deleteById(gatewayidx) > 0;
    }
}